home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Developer Utilities / Installer 4.0.3 SDK / Script Examples / Action Atoms [inaa] Example / progressAtom.c < prev    next >
Encoding:
Text File  |  1994-11-15  |  5.3 KB  |  141 lines  |  [TEXT/MPS ]

  1. //
  2. //    ProgressAtom.c
  3. //
  4. //        Demonstration of a format2 action atom displaying 
  5. //        advancement of the installer dialog progress bar.
  6. //
  7. //        When the action atom will take a long time to complete its task(s), 
  8. //        it is a good idea to present the user with some kind of comforting 
  9. //        sign that the machine is performing normally. Using the methods outlined 
  10. //        in this example, scriptwriters can show progress in the bar
  11. //        displayed in the installer dialog.
  12. //
  13. //        Every format2 action atom is allocated 100 increments
  14. //        from the installer progress bar to use as the action atom 
  15. //        performs its duties. Error checking is performed by the installer
  16. //        so that even if the action atom requests progress display 
  17. //        beyond the 100 allotted increments, the installer will 
  18. //        limit the progress to 100 increments.
  19. //
  20. //        It should be noted that although there are 100 increments
  21. //        alloted to the action atom, progress is not displayed with
  22. //        each and every increment registered from the action atom.
  23. //
  24. //        mark young • 08/18/94
  25. //
  26. //        Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
  27. //
  28.  
  29. #include <Traps.h>
  30. #include <Types.h>
  31. #include <dialogs.h>
  32. #include <TextUtils.h>
  33.  
  34. // these lines have been added for Wasabi Installer Debugger support
  35. #include "CallbackDispatcherHeader.h"
  36. #include "ActionHandlerHeader.h"
  37. #include "InstallerMemoryFuncsHeader.h"
  38.  
  39. // this line replaces #include "ActionAtomIntf.h" used in Installer 3.x action atoms
  40. #include "ActionAtomHeader.h"
  41.  
  42. // this is needed for highliting the default button in dialog
  43. pascal OSErr SetDialogDefaultItem (    DialogPtr theDialog,
  44.                                     short newItem         ) = {0x303C,0x0304,0xAA68};
  45.  
  46. // this is used to print one line out to the Wasabi Installer Debugger 
  47. void PrintLine( ProcPtr pCallBackProcPtr, Str255 pParam0, Str255 pParam1, Str255 pParam2, Str255 pParam3 );
  48.  
  49. // external function to send text to Wasabi Installer Debugger
  50. void RegisterScriptAction(     CallBackProcPtr    pCallBackProcPtr,
  51.                             short            actionClassID,
  52.                             short            actionIdentifier,
  53.                             void*            param0,
  54.                             void*            param1,
  55.                             void*            param2,
  56.                             void*            param3,
  57.                             void*            resultPtr  );
  58.  
  59. // print the parameter block record information to Wasabi Installer Debugger
  60. void PrintAAParamBlock( ActionAtom2PBPtr atomRecPtr );
  61.  
  62. // NOTE: The name of this function 'ActionAtomFormat2' should
  63. // match that specified in the -m option for the line in the
  64. // makefile that compiles this action atom.
  65. ActionAtomResult ActionAtomFormat2( ActionAtom2PBPtr atomRecPtr )
  66. {
  67.     short        i = 0;                    // 0..100 progress bar increments    
  68.     long        lastTickCount = 0;        // last check at the time
  69.     long        currentTickCount = 0;    // this check at the time
  70.     
  71.     // print the parameter block record information to Wasabi Installer Debugger
  72.     PrintAAParamBlock( atomRecPtr );
  73.  
  74.     while ( i < 100 )
  75.         {
  76.         // get the time in ticks
  77.         lastTickCount = currentTickCount = TickCount();
  78.         
  79.         // wait five seconds ( non-CPU specific method )
  80.         while ( currentTickCount < ( lastTickCount + 5 ))
  81.             // keep getting the time in ticks
  82.             currentTickCount = TickCount();
  83.         
  84.         // tell the silly progress bar to move along
  85.         IncrementStatusBar( atomRecPtr->fCallBackProcPtr, 1 );
  86.         i++;
  87.         }
  88.  
  89.     // print the return value to Wasabi Installer Debugger
  90.     PrintLine( atomRecPtr->fCallBackProcPtr, "\p\n", 
  91.                 "\pProgress Bar Action Atom - done - returning 0 ...", "\p\n", "\p" );
  92.  
  93.     return( 0 );
  94.  
  95. }
  96.  
  97. // shoot one line of text out to the Wasabi Installer Debugger
  98. void PrintLine( ProcPtr pCallBackProcPtr, Str255 pParam0, Str255 pParam1, Str255 pParam2, Str255 pParam3 )
  99. {
  100.     long    theResult;
  101.     RegisterScriptAction( pCallBackProcPtr, kDebuggingAction, kGenericDebugActID, pParam0, pParam1, pParam2, pParam3, &theResult );    
  102. }
  103.  
  104. void PrintAAParamBlock( ActionAtom2PBPtr atomRecPtr )
  105. {
  106.     Str255        numStr;
  107.     
  108.     PrintLine( atomRecPtr->fCallBackProcPtr, "\p\n", "\pParameter Block for Progress Bar Action Atom ...", "\p", "\p" );
  109.     
  110.     NumToString( atomRecPtr->fMessageID, numStr );
  111.     PrintLine(   atomRecPtr->fCallBackProcPtr, "\p", "\pfMessageID : ", numStr,  "\p" );
  112.     
  113.     NumToString( (long) atomRecPtr->fStaticDataHdl, numStr );
  114.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfStaticDataHdl : ", numStr, "\p", "\p" );
  115.     
  116.     NumToString( (long) atomRecPtr->fTargetVRefNum, numStr );
  117.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfTargetVRefNum : ", numStr, "\p", "\p" );
  118.     
  119.     NumToString( (long) atomRecPtr->fTargetFolderDirID, numStr );
  120.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfTargetFolderDirID : ", numStr, "\p", "\p" );
  121.     
  122.     NumToString( (long) atomRecPtr->fSystemVRefNum, numStr );
  123.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfSystemVRefNum : ", numStr, "\p", "\p" );
  124.     
  125.     NumToString( (long) atomRecPtr->fSystemBlessedDirID, numStr );
  126.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfSystemBlessedDirID : ", numStr, "\p", "\p" );
  127.     
  128.     NumToString( (long) atomRecPtr->fRefCon, numStr );
  129.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfRefCon : ", numStr, "\p", "\p" );
  130.     
  131.     NumToString( (long) atomRecPtr->fDoingInstall, numStr );
  132.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfDoingInstall : ", numStr, "\p", "\p" );
  133.     
  134.     NumToString( (long) atomRecPtr->fDidLiveUpdate, numStr );
  135.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfDidLiveUpdate : ", numStr, "\p", "\p" );
  136.     
  137.     NumToString( (long) atomRecPtr->fInstallerTempDirID, numStr );
  138.     PrintLine(   atomRecPtr->fCallBackProcPtr,  "\pfInstallerTempDirID : ", numStr, "\p", "\p\n" );
  139.     
  140. }
  141.